import { createI18n } from 'vue-i18n'
import zhcn from './zh-cn'
import en from './en'
import ar from './ar'
import jp from './jp'
import fa from './fa'
import fr from './fr'
import ur from './ur'
import zhtw from './zh-tw'
import zhhk from './zh-hk'


const messages = {
  ar,
  en,
  zhcn,
  zhtw,
  zhhk,
  fr,
  jp,
  fa,
  ur
}

const defaultLang = 'zhcn'
const language = (navigator.language || defaultLang).toLocaleLowerCase() // 这是获取浏览器的语言

const i18n = createI18n({
  legacy: false,
  locale: localStorage.getItem('lang') || language.replace('-', '') || defaultLang, // 首先从缓存里拿，没有的话就用浏览器语言，
  fallbackLocale: defaultLang, // 设置备用语言
  messages, 
})


export default i18n